-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate @storybook/channel-postmessage to TypeScript #5154
Conversation
Codecov Report
@@ Coverage Diff @@
## next #5154 +/- ##
==========================================
- Coverage 35.25% 35.23% -0.02%
==========================================
Files 596 596
Lines 7397 7401 +4
Branches 1010 1015 +5
==========================================
Hits 2608 2608
- Misses 4276 4285 +9
+ Partials 513 508 -5
Continue to review full report at Codecov.
|
if (!iframeWindow) { | ||
return new Promise((resolve, reject) => { | ||
this._buffer.push({ event, resolve, reject }); | ||
this.buffer.push({ event, resolve, reject }); | ||
}); | ||
} | ||
const data = stringify({ key: KEY, event }); | ||
iframeWindow.postMessage(data, '*'); | ||
return Promise.resolve(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Promise.resolve(null)
feels odd
In all return
cases, the return value should be void
right? This existed before your PR, I just thought this should be fixed because this return value is part of the public API now
@ndelangen what do you think?
Like this:
send(event: ChannelEvent): Promise<void> {
const iframeWindow = this.getWindow();
if (!iframeWindow) {
return new Promise((resolve, reject) => {
this._buffer.push({ event, resolve, reject });
this.buffer.push({ event, resolve, reject });
});
}
const data = stringify({ key: KEY, event });
iframeWindow.postMessage(data, '*');
return Promise.resolve();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with whatever you and @ndelangen decide. Happy to make the patch if you want me to.
Issue: #5030
What I did
Migrate
@storybook/channel-postmessage
to TypeScriptHow to test
There are no existing tests for this module.